// ---------------------------------------------------------------------------------------------------------------------------------
// Desktop Icons File for PCMod
// [CLIENTSIDE]
// Revision: 1
// ---------------------------------------------------------------------------------------------------------------------------------


// ---------------------------------------------------------------------------------------------------------------------------------
// pc_builddesktopicons: Builds the desktop icons from the stored table
// ---------------------------------------------------------------------------------------------------------------------------------
function pc_builddesktopicons()
	pc_cleardesktopicons()
	local iconw = 64
	local iconh = 64
	local progs = C_PC.PList
	local obj = DInterface:GetPanel( "desktop" )
	local ycnt = math.floor((obj:GetTall()-20)/iconh)
	local xcnt = math.floor(obj:GetWide()/iconw)
	local cy = 0
	local cx = 1
	for k, v in pairs( progs ) do
		cy = cy + 1
		if (cy > ycnt) then
			cy = 1
			cx = cx + 1
		end
		local pn = vgui.Create( "DesktopIcon" )
		pn:SetParent( obj )
		pn:SetPos( (cx-1)*iconw, (cy-1)*iconh )
		pn:SetSize( iconw, iconh )
		pn:Setup( v )
		// pn:Setup( "PrinterSoft" )
		DesktopIcons[ k ] = pn
	end
end

// ---------------------------------------------------------------------------------------------------------------------------------
// pc_cleardesktop: Clears the desktop
// ---------------------------------------------------------------------------------------------------------------------------------
function pc_cleardesktopicons()
	for k, v in pairs( DesktopIcons ) do
		if (v) then v:Remove() end
	end
	DesktopIcons = {}
end

// ---------------------------------------------------------------------------------------------------------------------------------
// pc_hidedesktopicons: Hides the desktop icons
// ---------------------------------------------------------------------------------------------------------------------------------
function pc_hidedesktopicons()
	for k, v in pairs( DesktopIcons ) do
		if (v) then v:SetVisible( false ) end
	end
end

// ---------------------------------------------------------------------------------------------------------------------------------
// pc_showdesktopicons: Shows the desktop icons
// ---------------------------------------------------------------------------------------------------------------------------------
function pc_showdesktopicons()
	for k, v in pairs( DesktopIcons ) do
		if (v) then v:SetVisible( true ) end
	end
end